import axios from "axios";

const instance = axios.create({
  timeout: 60 * 1000,
});

instance.interceptors.response.use(
  (response) => {
    const res = response.data || {};

    if (res.code === 200) {
      return Promise.resolve(res?.data || '');
    } else {
      return Promise.reject(res.msg || "Unknown error");
    }
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default instance;